<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>团队展示|蜗牛宠物领养平台</title>

    <link rel="shortcut icon" th:href="@{/asserts/images/favicon.ico}" type="image/x-icon"/>
    <!-- Bootstrap的css -->
    <link rel="stylesheet" th:href="@{/asserts/bootstrap3.4.1/css/bootstrap.min.css}">
    <!-- jQuery本地-->
    <script th:src="@{/asserts/js/jQuery-3.6.0.js}"></script>
    <!-- 加载本地js -->
    <script th:src="@{/asserts/bootstrap3.4.1/js/bootstrap.min.js}"></script>
    <!-- 加载common.css -->
    <link rel="stylesheet" th:href="@{/asserts/css/common.css}"/>
    <!-- 加载页头页尾css -->
    <link rel="stylesheet" th:href="@{/asserts/css/top.css}"/>
    <link rel="stylesheet" th:href="@{/asserts/css/foot.css}"/>
    <!-- 加载页头页尾js -->
    <script th:src="@{/asserts/js/top.js}"></script>

    <!--引入本頁面的css-->
    <link rel="stylesheet" th:href="@{/asserts/css/team.css}"/>

</head>
<body>
<!-- 页头 -->
<nav th:replace="nav::headerBar"></nav>
<div class="container">

    <h1 class="focus-in-contract-bck">
        我们的团队
    </h1>
    <section id="home-slider">
        <div class="container">
            <div class="main-slider animate-in">
                <div class="slide-text">
                    <h1>优秀、执着、有爱心</h1>
                    <br/>
                    <br/>
                    <br/>
                    <h4> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;---来欣赏我们的团队风采
                    </h4>
                    <div style="height: 50px"></div>
                    <button type="button" class="btn btn-common" data-toggle="modal" data-target="#myModal">加入我们
                    </button>

                </div>
                <!-- Modal -->
                <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
                    <div class="modal-dialog" role="document">
                        <div class="modal-content">
                            <div class="modal-header">
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                        aria-hidden="true">&times;</span></button>
                                <h4 class="modal-title" id="myModalLabel">加入我们</h4>
                            </div>
                            <div class="modal-body">
                                <div class="contact-form bottom">
                                    <form id="applyForm">
                                        <h5>申请成为我们的志愿者，让我们共同守护流浪宠物</h5>
                                        <h5>&nbsp;</h5>
                                        <div class="form-group">
                    <textarea name="message" id="message" required="required" class="form-control" rows="8"
                              placeholder="在这里，你可以输入你的申请理由"></textarea>
                                        </div>
                                        <div class="form-group">
                                            <button type="submit" name="submit" class="btn btn-submit"
                                                    onclick="apply(event)">申请
                                            </button>
                                        </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <img th:src="@{/asserts/images/teamImg/house.png}" class="img-responsive slider-house"
                     alt="slider image">
                <img th:src="@{/asserts/images/teamImg/circle1.png}" class="slider-circle1" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/circle2.png}" class="slider-circle2" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/cloud1.png}" class="slider-cloud1" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/cloud2.png}" class="slider-cloud2" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/cloud3.png}" class="slider-cloud3" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/sun.png}" class="slider-sun" alt="slider image">
                <img th:src="@{/asserts/images/teamImg/cycle.png}" class="slider-cycle" alt="">
            </div>
        </div>
        <div class="container">
            <div
                    class="wp-block-qubely-row alignfull qubely-section qubely-block-0e046a">
                <div class="qubely-row-overlay"></div>
                <div class="qubely-container ">
                    <div class="qubely-row">
                        <div class="wp-block-qubely-column qubely-column qubely-column-front qubely-block-4320fd"
                             th:each="t:${teamList}">
                            <div class="qubely-column-inner">
                                <a class="wp-block-qubely-wrapper qubely-block-adb3e1"
                                   th:href="'teamList?name='+${t.managerName}">
                                    <div class="qubely-block-wrapper-block ">
                                        <div class="wp-block-qubely-team qubely-block-7c0b77">
                                            <div class="qubely-block-team  qubely-team-layout-1">
                                                <div class="qubely-team-image-wrapper"><img class="qubely-team-image"
                                                                                            th:src="@{'https://woniu-adopt.oss-cn-hangzhou.aliyuncs.com/adoptImages/'+${t.pic}}"
                                                                                            srcset=""
                                                                                            alt="Aartom Danisky"></div>
                                                <div class="qubely-team-content">
                                                    <div class="qubely-team-content-inner"><span
                                                            class="qubely-team-name" th:text="${t.managerName}"></span>
                                                        <div class="qubely-team-designation-container"><span
                                                                class="qubely-team-designation"
                                                                th:text="${t.typeName}"></span>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </a>
                            </div>
                            <div th:if="${tStat.count%3==0}">
                                <div style="height: 20px;"></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <br/>
        </div>
    </section>
</div>
<!-- 页尾 -->
<footer th:replace="nav::footBar"></footer>
</body>
</html>
<script>
    function apply(event) {
        event.preventDefault();
        //之所以这里的表单提交拦截不起作用，是因为此方法内的存在无法解析的空对象，故此方法无效。解决方法：点前加问号
        let volunteerStatus = "[[${session?.loginUser?.volunteerStatus}]]";
        if (volunteerStatus == '') {
            if ('[[${session?.loginUser}]]' == '') {
                alert('请先登录！');
                $("#myModal").modal('toggle');
                return;
            }
            let message = $("#message").val();
            if (message == '') {
                alert("请输入申请理由！");
                return;
            }
            if (message.length < 10 && message.length !== 0) {
                alert("请至少输入10字以上的申请理由！");
                return;
            }
            let data = {
                message: message,
                option: 0
            }
            let url = '[[@{/user/beVolunteer}]]';
            $.ajax({
                url: url,
                data: data,
                type: 'post',
                dataType: 'json',
                success: res => {
                    if (res == 0) {
                        $("#myModal").modal('toggle');
                        alert("申请成功，请等待审核或者在个人中心修改您的申请信息");
                        location.reload();
                    } else {
                        alert("系统错误，请联系管理员");
                        location.reload();
                    }
                }
            })
        } else if (volunteerStatus == 0) {
            alert("申请失败！您已经提交过您的申请，请等待管理员审核或者在个人中心修改您的申请，无需再次申请！");
            $("#myModal").modal('toggle');
        } else if (volunteerStatus == 1) {
            alert("申请失败！您已经是我们的志愿者，无需重复加入!");
            $("#myModal").modal('toggle');
        } else if (volunteerStatus == 2) {
            alert("申请失败！我们拒绝了您的申请，您可以在个人中心再次申请");
            $("#myModal").modal('toggle');
        }

    }

</script>